package com.xinqi.modules.homework.homework.service;

import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.xinqi.common.base.response.PageInfo;
import com.xinqi.common.base.response.Param;
import com.xinqi.common.mybatis.data.service.BaseService;
import com.xinqi.modules.homework.homework.domain.CourseHomeworkEntity;
import com.xinqi.modules.homework.homework.domain.CourseHomeworkStudentLogEntity;
import com.xinqi.modules.homework.homework.dto.req.*;
import com.xinqi.modules.homework.homework.dto.rsp.*;

import java.math.BigDecimal;
import java.util.Collection;
import java.util.List;

/**
 * 服务层
 *
 * @author: system
 * @date: 2023/03/08
 */
public interface CourseHomeworkStudentLogService extends BaseService<CourseHomeworkStudentLogEntity> {

    /**
     * 分页查询 列表数据
     */
    PageInfo<CourseHomeworkStudentResultDTO> homeworkStudentList(Param pageable, CourseHomeworkStudentLogQueryDTO dto);

    /**
     * 根据作业内容轮数查询学生作业详情
     */
    CourseHomeworkStudentListResultDto homeworkStudentInfoList(CourseHomeworkStudentLogQueryDTO dto);

    /**
     * 学生作业分页
     *
     * @param page
     * @param dto
     * @return
     */
    PageInfo<CourseHomeworkStudentInfoResultDTO> homeworkStudentPage(Page<CourseHomeworkStudentInfoResultDTO> page,
                                                                     CourseHomeworkStudentLogQueryDTO dto);

    CourseHomeworkTimerResultDTO findSubmitStatus(Long contentId);

    /**
     * 查询 数据
     */
    List<CourseHomeworkStudentLogResultDTO> find(CourseHomeworkStudentLogQueryDTO query);

    List<CourseHomeworkStudentInfoResultDTO> homeworkStudentInfoListByStatus(CourseHomeworkStudentBaseDTO dto);

    /**
     * 根据id查询 数据
     */
    CourseHomeworkStudentLogResultDTO findById(Long id);

    /**
     * 查询学生提交作业详情
     */
    CourseHomeworkStudentInfoResultDTO findStudentDetail(CourseHomeworkStudentDetailDTO query);

    /**
     * 根据参数查询 数据
     */
    CourseHomeworkStudentInfoResultDTO findByParam(CourseHomeworkStudentLogQueryDTO query);

    /**
     * 提交作业
     */
    Long insert(CourseHomeworkStudentLogCreateDTO dto);

    /**
     * 提交作业更新统计信息
     */
    void refreshHomeworkAllTotal(Long contentId, Long studentId, Integer times);

    /**
     * 根据id修改 数据
     */
    Boolean updateById(CourseHomeworkStudentLogUpdateDTO dto);

    /**
     * 判断更新学生作业提交记录信息
     */
    @Deprecated
    Boolean checkUpdate(CourseHomeworkStudentLogUpdateDTO dto);

    /**
     * 同步作业学生数据
     */
    void syncStudent(CourseHomeworkStudentLogCreateDTO dto);

    /**
     * 新增班级学生作业记录数据
     *
     * @param homeworkEntityList 作业
     */
    void insertClassStudentLogBatch(List<CourseHomeworkEntity> homeworkEntityList);

    void insertGroupStudentLogBatch(List<CourseHomeworkEntity> entity);

    /**
     * 同步小组作业学生数据
     */
    void syncGroupStudent(CourseHomeworkStudentLogCreateDTO dto, String groupIds);

    /**
     * 根据学生id结合 催交 课程栏目作业数据
     */
    boolean call(CourseHomeworkStudentLogQueryDTO dto);

    /**
     * 根据学生id结合 打回 课程栏目作业数据
     */
    boolean repulse(List<CourseHomeworkStudentLogUpdateDTO> list);

    /**
     * 根据学生id结合 已阅 课程栏目作业数据
     */
    boolean readOver(List<CourseHomeworkStudentApproveDTO> list);

    /**
     * 根据学生id结合 已批 课程栏目作业数据
     */
    boolean approved(List<CourseHomeworkStudentApproveDTO> list);

    /**
     * 老师评语
     */
    boolean teachComment(List<CourseHomeworkStudentApproveDTO> list);

    /**
     * 历史评语
     */
    List<String> historyComment(CourseHomeworkStudentBaseDTO dto);

    /**
     * 根据学生记录Id 分享
     */
    boolean share(CourseHomeworkStudentLogShareDTO dto);

    /**
     * 修改学生参与状态
     */
    boolean parTake(Long id);

    /**
     * 学生查询 分享作业
     */
    List<CourseHomeworkStudentInfoResultDTO> findShare(CourseHomeworkStudentLogQueryDTO query);

    /**
     * 已参与未参与列表
     */
    List<CourseHomeworkStudentPartakeResultDTO> partakeList(CourseHomeworkStudentLogQueryDTO dto);

    /**
     * 删除多余的学生打卡轮数
     */
    boolean deleteByHomework(CourseHomeworkEntity entity);

    /**
     * 查询作业学生最大分数
     */
    BigDecimal homeworkMaxStudentScore(Long contentId);

    /**
     * 查询学生最后一次记录
     */
    CourseHomeworkStudentLogEntity getLast(Long contentId, Long studentId, Long classId);

    List<CourseHomeworkStudentLogEntity> findByContentIdAndStudentIds(Long contentId, Collection<Long> studentIds);

    long homeworkStudentTotal(CourseHomeworkStudentLogQueryDTO dto);


    List<CourseHomeworkStudentLogResultDTO> studentRepeatList(CourseHomeworkStudentDetailDTO dto);

    List<Integer> studentRepeatSelect(CourseHomeworkStudentDetailDTO dto);

    List<Integer> teacherRepeatSelect(Long contentId);

    void cancelShare(Long studentHomeworkId);

    Integer findSharedCount(CourseHomeworkStudentLogQueryDTO dto, Integer taskStatus);

}
